package com.pp.controller;


import com.pp.bean.GovIndex;
import com.pp.bean.GovStory;
import com.pp.bean.GovStoryInfo;
import com.pp.service.GovStoryInfoService;
import com.pp.service.GovStoryService;
import com.pp.util.Respons.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 品牌故事详情 前端控制器
 * </p>
 *
 * @author 冯政尚
 * @since 2019-04-02
 */
@Controller
@RequestMapping("/govStoryInfo")
@Api(value = "品牌故事详情Controller", tags = {"关品牌故事详情类型类"})
public class GovStoryInfoController {


    @Autowired
    GovStoryInfoService govStoryInfoService;
    @Autowired
    GovStoryService govStoryService;


    @RequestMapping(value = "insert",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "新增品牌故事详情")
    public Map insert(@RequestBody GovStoryInfo govStoryInfo){


        GovStory govStory = new GovStory();
        govStoryInfo.setRelactionId(govStory.getId());
        System.out.println("govStory:"+govStory);

        if(govStoryInfoService.save(govStoryInfo)){
            return ResponseUtil.getSuccessMap();
        }
        return ResponseUtil.getExceptionMap();
    }

    @RequestMapping(value = "deleteById",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除品牌故事详情")
    public Map deleteById(@RequestBody GovStoryInfo govStoryInfo){
        if(govStoryInfoService.removeById(govStoryInfo)){
            return ResponseUtil.getSuccessMap();
        }
        return ResponseUtil.getExceptionMap();
    }


    @RequestMapping(value = "updateById",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "修改品牌故事详情")
    public Map updateById(@RequestBody GovStoryInfo govStoryInfo){
        if(govStoryInfoService.updateById(govStoryInfo)){
            return ResponseUtil.getSuccessMap();
        }
        return ResponseUtil.getExceptionMap();
    }


    @RequestMapping(value = "select",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询品牌故事详情")
    public List<GovStoryInfo> select(){
        return govStoryInfoService.list();
    }


}
